package com.gitee.feizns.itrip.personal.search.controller;

import com.gitee.feizns.itrip.personal.beans.dto.Dto;
import com.gitee.feizns.itrip.personal.search.entity.ao.ForAcceptHotelListByHotCity;
import com.gitee.feizns.itrip.personal.search.entity.ao.ForAcceptSearchItripHotelPage;
import com.gitee.feizns.itrip.personal.search.service.HotelService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author feizns
 * @since 2019/1/4 0004
 */
@RestController
@RequestMapping("/api")
public class HotelController {

    @Autowired
    private HotelService hotelService;

    @PostMapping("hotellist/searchItripHotelListByHotCity")
    public Dto searchItripHotelListByHotCity(@RequestBody ForAcceptHotelListByHotCity params) {
        if ( params != null && params.getCityId() != null ) {
            ForAcceptSearchItripHotelPage condition = new ForAcceptSearchItripHotelPage();

            condition.setCityId(params.getCityId());

            if ( params != null && params.getCount() != null )
                condition.setPageSize(params.getCount());

            return Dto.getSuccessDto(null, hotelService.search(condition).getRows());
        }

        return Dto.getSuccessDto(null, null);
    }

    @PostMapping("/hotellist/searchItripHotelPage")
    public Dto searchItripHotelPage(@RequestBody ForAcceptSearchItripHotelPage condition) {
        return Dto.getSuccessDto(null, hotelService.search(condition));
    }

}
